package com.maimeng.Mapper;

import com.maimeng.Model.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

@Mapper
public interface UserMapper {
    @Delete({
        "delete from user",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Select("select * from user limit 100")
    User[] userAll();
    @Insert({
        "insert into user (id, telephone, ",
        "nickname, avatar, ",
        "birthday, sex, signature, ",
        "qudao, registerType, ",
        "level, enableEmChat, ",
        "status, qq, email, ",
        "createTime, modifyTime, ",
        "registerSource)",
        "values (#{id,jdbcType=BIGINT}, #{telephone,jdbcType=VARCHAR}, ",
        "#{nickname,jdbcType=VARCHAR}, #{avatar,jdbcType=VARCHAR}, ",
        "#{birthday,jdbcType=DATE}, #{sex,jdbcType=TINYINT}, #{signature,jdbcType=VARCHAR}, ",
        "#{qudao,jdbcType=VARCHAR}, #{registertype,jdbcType=TINYINT}, ",
        "#{level,jdbcType=TINYINT}, #{enableemchat,jdbcType=TINYINT}, ",
        "#{status,jdbcType=TINYINT}, #{qq,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, ",
        "#{createtime,jdbcType=TIMESTAMP}, #{modifytime,jdbcType=TIMESTAMP}, ",
        "#{registersource,jdbcType=BIGINT})"
    })
    int insert(User record);

    @InsertProvider(type=UserSqlProvider.class, method="insertSelective")
    int insertSelective(User record);

    @Select({
        "select",
        "id, telephone, nickname, avatar, birthday, sex, signature, qudao, registerType, ",
        "level, enableEmChat, status, qq, email, createTime, modifyTime, registerSource",
        "from user",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="telephone", property="telephone", jdbcType=JdbcType.VARCHAR),
        @Result(column="nickname", property="nickname", jdbcType=JdbcType.VARCHAR),
        @Result(column="avatar", property="avatar", jdbcType=JdbcType.VARCHAR),
        @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
        @Result(column="sex", property="sex", jdbcType=JdbcType.TINYINT),
        @Result(column="signature", property="signature", jdbcType=JdbcType.VARCHAR),
        @Result(column="qudao", property="qudao", jdbcType=JdbcType.VARCHAR),
        @Result(column="registerType", property="registertype", jdbcType=JdbcType.TINYINT),
        @Result(column="level", property="level", jdbcType=JdbcType.TINYINT),
        @Result(column="enableEmChat", property="enableemchat", jdbcType=JdbcType.TINYINT),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
        @Result(column="qq", property="qq", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="createTime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modifyTime", property="modifytime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="registerSource", property="registersource", jdbcType=JdbcType.BIGINT)
    })
    User selectByPrimaryKey(Long id);

    @UpdateProvider(type=UserSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(User record);

    @Update({
        "update user",
        "set telephone = #{telephone,jdbcType=VARCHAR},",
          "nickname = #{nickname,jdbcType=VARCHAR},",
          "avatar = #{avatar,jdbcType=VARCHAR},",
          "birthday = #{birthday,jdbcType=DATE},",
          "sex = #{sex,jdbcType=TINYINT},",
          "signature = #{signature,jdbcType=VARCHAR},",
          "qudao = #{qudao,jdbcType=VARCHAR},",
          "registerType = #{registertype,jdbcType=TINYINT},",
          "level = #{level,jdbcType=TINYINT},",
          "enableEmChat = #{enableemchat,jdbcType=TINYINT},",
          "status = #{status,jdbcType=TINYINT},",
          "qq = #{qq,jdbcType=VARCHAR},",
          "email = #{email,jdbcType=VARCHAR},",
          "createTime = #{createtime,jdbcType=TIMESTAMP},",
          "modifyTime = #{modifytime,jdbcType=TIMESTAMP},",
          "registerSource = #{registersource,jdbcType=BIGINT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(User record);
}